package com.hzgj.bcl.soa.command;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Maps;
import com.hzgj.bcl.stats.RedisKey;
import redis.clients.jedis.Tuple;

import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2016/9/2.
 */
public class InvokeErrorCountCommand extends InvokeCommand {

    @Override
    String handleNode(String baseKey, long start, long end) {
        Set<Tuple> tuples = redisClient.zrangeByScoreWithScores(RedisKey.getErrorCount(baseKey), start, end);
        Map<String, String> map = Maps.newHashMap();
        String result = buildTuple(tuples);
        map.put("name", "errorCount");
        map.put("data", result);
        return JSON.toJSONString(map);
    }

    @Override
    public String getName() {
        return "invoke_error_count";
    }
}
